import Vue from 'vue'
import Vuex from 'vuex'
import { filtrationRouter } from '../router'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    // 获取的动态路由
    Menslist: JSON.parse(sessionStorage.getItem('Menslist') || '[]'),
    nikeName: '',
    // 入库申请表格
    InOrdersModal: [],
    //客户编号数组
    accArray: [],
    //仓库数组
    warehouse: [],
    //客户端仓库
    clientWareHouse: [],
    //物流商
    logisticsArray: [],
  },
  getters: {
    // 计算出真实路由
    getRealMenus(state) {
      return filtrationRouter(state.Menslist)
    }
  },
  mutations: {
    //登录获取后台权限动态路由
    MENUSLIST(state, data) {
      state.Menslist = data
      sessionStorage.setItem('Menslist', JSON.stringify(data))
    },
    // 昵称
    NIKENAME(state, data) {
      state.nikeName = data
    },
    //客户编号
    ACCARRAY(state, data) {
      state.accArray = data;
    },
    //全部仓库
    WAREHOUSE(state, data) {
      state.warehouse = data;

    },
    //客户端全部仓库
    CLIENTWAREHOUSE(state, data) {
      state.clientWareHouse = data;
    },
    //物流商
    LOGISTICS(state, data) {
      state.logisticsArray = data;
    },
    //入库申请表格数据
    tabListData(state, data) {
      data.forEach((item) => {
        item.createTime = item.createTime.replace('T', " ");
      })
      state.InOrdersModal = data;
    },

  },
  actions: {
  },
  modules: {
  }
})
